package com.wfm;

import org.redisson.Redisson;
import org.redisson.api.RBucket;
import org.redisson.api.RList;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

public class RedissonExample {
    public static void main(String[] args) throws InterruptedException {
        // 创建配置对象
        Config config = new Config();
        config.useSingleServer()
              .setAddress("redis://127.0.0.1:6379");// 默认地址是 redis://127.0.0.1:6379


        // 创建 Redisson 客户端
        RedissonClient redisson = Redisson.create(config);

//        // 使用 Redisson 客户端操作 Redis
//        RBucket<String> bucket = redisson.getBucket("myKey");
//        bucket.set("Hello, Redisson!");
//
//        // 获取值
//        String value = bucket.get();
//        System.out.println("Value from Redis: " + value);

        // 根据键获取值
        RBucket<Object> myKey = redisson.getBucket("myKey");
        String o = (String)myKey.get();
        System.out.println(o);

        Thread.sleep(3000);

        // 关闭 Redisson 客户端
        redisson.shutdown();
    }
}